package com.sy.cloud.wechat.entity.message;

import com.sy.cloud.wechat.entity.message.AcceptableXmlMessage;
import com.sy.cloud.wechat.entity.message.ReturnableXmlMessage;
import com.sy.cloud.wechat.entity.message.SendableApiMessage;
import com.sy.cloud.wechat.entity.message.WeChatMessage;
import lombok.Getter;
import lombok.Setter;

/**
 * Created by zhuwenquan on 2017/9/10.
 * 被动回复图片消息
 */
@Getter
@Setter
public class ImageMessage extends WeChatMessage implements ReturnableXmlMessage,AcceptableXmlMessage,SendableApiMessage {
    public ImageMessage() {
        this.setMsgType(MsgType.image);
    }
    //消息id，64位整型
    private String msgId;
    //图片消息媒体id，可以调用多媒体文件下载接口拉取数据。
    private String mediaId;


    @Override
    public String toReturnXML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<xml>");
        sb.append("<ToUserName><![CDATA[" + this.getOpenId() + "]]></ToUserName>");
        sb.append("<FromUserName><![CDATA[" + this.getWeixinId() + "]]></FromUserName>");
        sb.append("<CreateTime>" + this.getCreateTime() + "</CreateTime>");
        sb.append("<MsgType><![CDATA[image]]></MsgType>");
        sb.append("<Image>");
        sb.append("<MediaId><![CDATA["+this.getMediaId()+"]]></MediaId>");
        sb.append("</Image>");
        sb.append("</xml>");
        return sb.toString();
    }

    @Override
    public String toReturnJSON() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
